#include<stdio.h>
#include<stdlib.h>
typedef struct STACK
{
	int *s;
	int t;
	int n;
} Stack;

void SetStack(Stack *ns,int n)
{
	ns->s=malloc(sizeof(int)*n);
	ns->t=n;
	ns->n=n;
}

int push(Stack *ns,int k)
{
	if(ns->t==0) return 0;
	ns->t--;
	ns->s[ns->t]=k;
	return 1;
}

int pop(Stack *ns)
{
	if(ns->t==ns->n) return 0;
	ns->t++;
	return 1;	
}

int gettop(Stack *ns)
{	
	if(ns->t==ns->n) return -1;
	return ns->s[ns->t];
}

